package com.zuikaku.servlet;

import com.zuikaku.pojo.Order;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class HomeServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/WEB-INF/page/home.jsp");
        List<Order> orderList =new ArrayList<>();
        Order o1 = new Order();
        o1.setOrderId(1);
        o1.setOrderName("蛋糕");
        o1.setOrderStatus(0);
        o1.setOrderPrice(10);
        o1.setCreateDate(new Date());
        Order o2 = new Order();
        o2.setOrderId(2);
        o2.setOrderName("啤酒");
        o2.setOrderStatus(1);
        o2.setOrderPrice(14);
        o2.setCreateDate(new Date());
        Order o3 = new Order();
        o3.setOrderId(3);
        o3.setOrderName("电视机");
        o3.setOrderStatus(2);
        o3.setOrderPrice(100);
        o3.setCreateDate(new Date());
        orderList.add(o1);
        orderList.add(o2);
        orderList.add(o3);
        req.setAttribute("orderList",orderList);
        requestDispatcher.forward(req,resp);
    }
}
